package routers

import (
	"github.com/gin-gonic/gin"
	"go-step/s9_cmdb/api/handler/host"
	"go-step/s9_cmdb/api/middleware"
)

func InitRouter() *gin.Engine {
	r := gin.Default()
	r.Use(middleware.Cors())

	hostGroup := r.Group("/api/cmdb/v1")
	{
		hostGroup.GET("/hosts", host.QueryHost)
		hostGroup.POST("/hosts", host.CreateHost)
		hostGroup.DELETE("/hosts/:id", host.DeleteHost)
		hostGroup.PUT("/hosts/:id", host.PutHost)
	}

	return r
}
